/**
 * @fileOverview    server入口.
 * @author          shaozhe.ysz@alibabapictures.com
 * @since           2016.07.28
 */

 const
    https = require('https'),
    fs = require('fs'),
    router = require('./main/router'),
    express = require('express');

const
    SERVER_PORT = 10086,
    HTTP_PORT = 80,
    HTTPS_PORT = 443;

var options = {
    key: fs.readFileSync(__dirname+'/ssl/key.pem'),
    cert: fs.readFileSync(__dirname+'/ssl/ssl.crt')
};

var app = express();

app.use('/',router);

var start = function(){

    console.log('\n\n\n\n\n\n\n');

    app.listen(HTTP_PORT, function () {
        console.log('Example app listening on port:' + HTTP_PORT);
    });

    https.createServer(options, app)
    .listen(HTTPS_PORT, function() {
        console.log('Example app listening on port:' + HTTPS_PORT);
    });

}

module.exports = {
    start:start,
    app:app
}